﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1 // рекурсия по семантике внутри скобок // обратная польская запись
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Введите выражение: ");
            string input = Console.ReadLine();
            List<object> ar = ParseString(input);
        }

        public static List<object> ParseString(string input)
        {
            char[] op = { '+', '-', '*', '/' };
            int indOfOperator = 0;
            int indLastAdded = -1;
            int numOfbracket=0;
            List<object> ar = new List<object>();
            for (int i = 0; i < input.Length; i++)
            {
                for (int j = 0; j < op.Length; j++)
                {
                    if (input[0] == op[j])
                    {
                        PrintHelp();
                        break;
                    }
                    if (input[i] == '(')
                    {
                        ar.Add(input[i]);
                        indLastAdded = i;
                        numOfbracket++;

                    }
                    if (input[i] == op[j] && input[i + 1] != op[j])
                    {
                        indOfOperator = i;
                       // if (input.Substring(indLastAdded+1,indOfOperator))
                        {
                            ar.Add(input.Substring(indLastAdded + 1, indOfOperator));
                            ar.Add(input[indOfOperator]);
                        }
                    }
                }
            }
            return ar;
        }

        public static bool ValidateOperand(string sub)
        {
            bool valid = false;
            double number = 0;
            bool isNumber = Double.TryParse(sub, out number);
            if (sub.StartsWith("@") && sub.Length == 1)
            {
                valid = true;
            }
            else if (isNumber == true)
            {
                valid = true;
            }

            for (int i = 0; i < sub.Length; i++)
            {
                if (((sub[0] >= 'A' && sub[0] <= 'Z') || (sub[0] >= 'a' && sub[0] <= 'z'))   // first element is letter  AND rest elements are digits or letters
                    && (sub[i] >= 'A' && sub[i] <= 'Z') || (sub[i] >= 'a' && sub[i] <= 'z') || (sub[i] >= '0' && sub[i] <= '9'))
                {
                    valid = true;
                }

                else
                {
                    valid = false;
                    break;
                }
            }
            return valid;
        }

        public static void PrintHelp()
        {
            Console.WriteLine("HELP  HELP  HELP");
        }

        static string FindBrackets(string input)
        {
            int openBrackIndex = -1;
            int closeBrackIndex = input.IndexOf(')');

            for (int i = closeBrackIndex - 1; i >= 0; i--)
            {
                if (input[i] == '(')
                {
                    openBrackIndex = i;
                }
            }
            string inBrackets = input.Substring(openBrackIndex + 1, closeBrackIndex - openBrackIndex+1);
            return inBrackets;
        }

        static double DoCal(string input)
        {
            double res = 0;

            return res;
        }
    }
}